/**
 * 
 */
package com.epam.entity;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author Nugumanova V.
 *
 */
public class Student extends Person {
	
	protected String groupName;
	protected List<Training> courses;

	public Student(long id, String userName, String password, Role status,
			String name, String iin, String address, String phone,
			Date dateOfBirth,  String groupName) {
		super(id, userName, password, status, name, iin, address, phone,
				dateOfBirth);
	
		this.groupName = groupName;
		courses = new ArrayList<Training>();		
	}
	
	public boolean addCourse(Training training) {
		if (courses.add(training)) {
			return true;
		} else {
			return false;
		}
	}
	
	@Override
	public String getName() {
		return super.getName();
	}
	
	public String getGroupName() {
		return groupName;
	}

	public List<Training> getCourses() {
		return courses;
	}

	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}
	public void setCourses(List<Training> courses) {
		this.courses.addAll( courses);
	}
	@Override
	public String toString() {
		StringBuilder s = new StringBuilder();
		s.append("Student # " ).append(id);
		s.append(super.toString()).append("\n");
		s.append("groupName ").append(groupName);
		for(Training training : courses){
			s.append(training.toString()).append("\n");
		}
		return s.toString();
	}

}
